package org.magicsoft.office.db;

import java.sql.Types;

import org.magicsoft.office.exception.UnsupportedException;

public enum SQLType {

	CHAR(Types.CHAR, "char", "char"),

	NCHAR(Types.NCHAR, "nchar", "nchar"),

	VARCHAR(Types.VARCHAR, "varchar", "varchar2"),

	NVARCHAR(Types.NVARCHAR, "nvarchar", "nvarchar2"),

	INTEGER(Types.INTEGER, "int", "number"),

	BIGINT(Types.BIGINT, "bigint", "number"),

	BOOLEAN(Types.BOOLEAN, "bit", "number"),

	BIT(Types.BIT, "bit", "number"),

	LONGNVARCHAR(Types.LONGNVARCHAR, "text", "clob"),

	LONGVARCHAR(Types.LONGVARCHAR, "text", "clob"),

	CLOB(Types.CLOB, "text", "clob"),

	NCLOB(Types.NCLOB, "text", "clob"),

	DATE(Types.DATE, "date", "date"),

	DECIMAL(Types.DECIMAL, "decimal", "number"),

	DOUBLE(Types.DOUBLE, "double", "number"),

	FLOAT(Types.FLOAT, "float", "number"),

	REAL(Types.REAL, "real", "number"),

	TINYINT(Types.TINYINT, "tinyint", "number"),

	LONGVARBINARY(Types.LONGVARBINARY, null, null),

	ARRAY(Types.ARRAY, null, null),

	BINARY(Types.BINARY, null, null),

	BLOB(Types.BLOB, null, null),

	DATALINK(Types.DATALINK, null, null),

	DISTINCT(Types.DISTINCT, null, null),

	JAVA_OBJECT(Types.JAVA_OBJECT, null, null),

	NULL(Types.NULL, null, null),

	NUMERIC(Types.NUMERIC, null, null),

	OTHER(Types.OTHER, null, null),

	REF(Types.REF, null, null),

	REF_CURSOR(Types.REF_CURSOR, null, null),

	ROWID(Types.ROWID, null, null),

	SMALLINT(Types.SMALLINT, null, null),

	SQLXML(Types.SQLXML, null, null),

	STRUCT(Types.STRUCT, null, null),

	TIME(Types.TIME, null, null),

	TIME_WITH_TIMEZONE(Types.TIME_WITH_TIMEZONE, null, null),

	TIMESTAMP(Types.TIMESTAMP, null, null),

	TIMESTAMP_WITH_TIMEZONE(Types.TIMESTAMP_WITH_TIMEZONE, null, null),

	VARBINARY(Types.VARBINARY, null, null);

	private int jdbcType = -1;

	private String mssqlType = null;

	private String oracleType = null;

	private SQLType(int jdbcType, String mssqlType, String oracleType) {
		this.jdbcType = jdbcType;
		this.mssqlType = mssqlType;
		this.oracleType = oracleType;
	}

	public int getJdbcType() {
		return jdbcType;
	}

	public String getDatabaseType(DatabaseType databaseType) {
		switch (databaseType) {
		case SQLSERVER:
			return this.mssqlType;
		case ORACLE:
			return this.oracleType;
		default:
			throw new UnsupportedException();
		}
	}

	public String getMssqlType() {
		return mssqlType;
	}

}
